package com.jsoft.jsofted.platform.vo;

import com.diboot.core.util.BeanUtils;
import com.jsoft.jsofted.platform.entity.RoleEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.LinkedList;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = false)
public class RoleBean extends RoleEntity {
    private String key;
    private String title;
    private String label;

    private List children;

    public void addChild(RoleBean bean) {
        if (children == null) {
            children = new LinkedList();
        }
        children.add(bean);
    }

    public void copyFrom(RoleEntity entity) {
        BeanUtils.copyProperties(entity, this);
        //
        this.setKey(entity.getId().toString());
        this.setTitle(entity.getName());
        this.setLabel(entity.getName());
    }
}